﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SharpShare.Diagnostics;

namespace SharpShare.Afp.Protocol.Handlers {
    internal class AfpByteRangeLockExtRequestHandler : IAfpRequestHandler {
        public byte CommandCode {
            get { return 59; }
        }

        public AfpResultCode Process(IAfpSession session, DsiHeader dsiHeader, AfpStream requestStream, AfpStream responseStream) {
            byte flags = requestStream.ReadUInt8();
            short forkId = requestStream.ReadInt16();
            long offset = requestStream.ReadInt64();
            long length = requestStream.ReadInt64();

            responseStream.WriteInt64(offset);

            Log.Add(session, EntryType.Debug, "Session '{0}' (un)locking range {1}-{2} on fork {3}.", session, offset, offset + length, forkId);

            return AfpResultCode.FPNoErr;
        }
    }
}
